﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Areas/Admin/Views/Shared/MainContent.Master" Inherits="System.Web.Mvc.ViewPage<MShop.Web.Components.Paging.PagedList<MShop.Core.Domain.Product>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Index
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <%=Html.Partial("ETTree",ViewData["itemcats"]) %>
<% using (Html.BeginForm())
   { %>
    <div id="rightBox">
        <div class="tabListBoxHead">
            <div style="float: left; padding-top: 3px;">                 
                <img src="/Content/add.png" width="16" height="16" border="0" align="absmiddle" style="margin-right: 3px;" />
                <%: Html.ActionLink("增加商品", "Create", "product", new { cid = RouteData.Values["id"] }, null)%>
            </div>
            <div style="float: right;">
                包括子分类：  <%=Html.CheckBox("includesub",Request.Params["includesub"]!=null?true:false) %>
                关键字：
                 <%=Html.TextBox("key",Request.Params["key"],new{@class="inputSearchBox"}) %>
                <input type="submit" value="查询" class="btn" />
            </div>
        </div>
      
        <div class="tabListBox">
            <table id="ETList" cellpadding="0" cellspacing="0">
                <thead>
                    <tr> <th width="100">
                            图片
                        </th>
                        <th width="100">
                            名称
                        </th>
                           <th>
                            分类
                        </th>
                        <th>
                            商城价
                        </th>
                       
                        <th width="100">
                            品牌
                        </th>
                         <th width="100">
                            数量
                        </th>
                         <th width="100">
                            图片
                        </th>
                        <th width="50">
                            操作
                        </th>
                    </tr>
                </thead>
                <tbody>
                    <% foreach (var item in Model)
                       { %>
                    <tr>
                    <td>
                    <img src='<%=item.ThumbImageUrl %>' style="width:120px;height:120px;" />
                    </td>
                        <td>
                            <%: Html.ActionLink(item.ProductName, "Edit", new { id = item.Id,cid=item.CId , actiontype = 1})%>                           
                            <a href="#this" title='加入广告' onclick="add2Ad(<%=item.Id %>);"><img src="/Content/add.png" /></a>
                        </td>
                          <td>
                            <%: item.ItemCat.Name%>
                        </td>
                        <td>
                            <%: item.ShopPrice%>
                        </td>
                        
                        <td>
                            <%: item.Brand!=null?item.Brand.Name:""%>
                        </td>
                         <td>
                            <%: item.CollectNum%>
                        </td>
                           <td>
                            <%=Html.ActionLink(item.ProductImg.Count.ToString(),"productpic",new{id=item.Id})%>
                        </td>
                        <td>
                           
                            <%=Html.ActionImageLink("/Content/edit.png", "Edit", new { cid = item.CId, id = item.Id, actiontype = 1 }, new { @title = "编辑商品基本信息" })%>
                            <%=Html.ActionImageLink("/Content/icon_system.png", "Edit", new { cid = item.CId, id = item.Id, actiontype = 2 }, new { @title = "编辑商品所有信息" })%>
                            <%=Html.ActionImageLink("/Content/remove.png", "Delete", new { id = item.Id }, new { onclick = "return confirm('确认删除商品，删除商品会把商品的所有相关信息删除?');", title = "删除" })%>
                           
                        </td>
                    </tr>
                    <% } %>
                </tbody>
            </table>
        </div>
        <%=Html.Pager(Model.PageSize,Model.PageNumber,Model.TotalItemCount,HttpVerbs.Post,"page") %>
        <input type="hidden" name="page" id="page"  />
       
    </div>

<%} %>
    <script type="text/javascript">
        $(document).ready(function () {
            var windowWidth = $("#rightBox").width();
            var windowHeight = $("#rightBox").height() - 60;
            $('.tabListBox').css({ 'width': windowWidth + 'px', 'height': windowHeight + 'px' });
            $(window).resize(function () {
                var windowWidth = $("#rightBox").width();
                var windowHeight = $("#rightBox").height() - 60;
                $('.tabListBox').css({ 'width': windowWidth + 'px', 'height': windowHeight + 'px' });
            });
            $('.tabListBox').fixedHeaderTable({ footer: false, cloneHeaderToFooter: false, autoResize: true, fixCol1: true });

            $('.tabListBox').find("tbody").find("tr").each(function (i) {
                if (i % 2 == 1) {
                    $(this).find("td").addClass("tr1");
                }
            });
            $('.tabListBox').find("tbody").find("tr").mouseover(function (i) {
                $(this).find("td").addClass("tr0");
            });
            $('.tabListBox').find("tbody").find("tr").mouseout(function (i) {
                $(this).find("td").removeClass("tr0");
            });

        });

        function add2Ad(index) { 
           var url='<% =Url.Action("AddId2Session","productad") %>/'+index+'';
           $.get(url, null, function (result) {
               if (result == '2') {
                   alert('该产品已经存在了');
               }
               else {
                   alert('产品成功加入');
               }
           });
        }
    </script>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="cphMeta" runat="server">
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="cphFooter" runat="server">
</asp:Content>
